package com.chinaunicom.emergency.repository;

import com.chinaunicom.emergency.model.YjglOrg;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * liliang
 * 2019-12-13
 */
@Repository
public interface OrgRepository extends JpaRepository<YjglOrg,String>, JpaSpecificationExecutor {

    List<YjglOrg> findByOrgIdInAndIsSoftDel(List<String> orgIdList, Integer i);
    List<YjglOrg> findAllByIsSoftDel(Integer i);

    YjglOrg findByPidAndIsSoftDel(String pid, Integer isSoftDel);

    YjglOrg findByParentIdAndOrgIdAndIsSoftDel(String parent, String orgId, Integer isSoftDel);

    YjglOrg findByParentIdAndOrgNameAndIsSoftDel(String parent, String orgName, Integer isSoftDel);

    List<YjglOrg> findByParentIdAndIsSoftDel(String parent, Integer isSoftDel);

    YjglOrg findByOrgIdAndIsSoftDel(String orgId, int i);

    @Query(nativeQuery = true, value = "select ORG_ID from YJGL_ORG where PARENT_ID = ?1 and IS_SOFT_DEL = 0")
    List<String> findOrgIdByParentId(String id);

    List<YjglOrg> findByParentIdAndIsSoftDelOrderByOrderNumAsc(String parentId, Integer isSoftDel);
}
